

#include <vector.h>
#include <fast_vec.h>

struct __xmm_reg {

  double low;
  double high;

};

void _print_addr(long addr);

vm_vector v1;
vm_vector v2;
vm_vector v3;
vm_vector tmp;

int main(){

  v1.x = 100.10;
  v1.y = 33.333;
  v1.z = 111.111;
  v1.w = 88.88;

  v2.x = 3.1;
  v2.y = .666;
  v2.z = -6.9;
  v2.w = 0;

  fprintf(stderr, "v1 addr: 0x%016lx\n", &v1);
  fprintf(stderr, "v2 addr: 0x%016lx\n", &v2);

  //_vm_asm_sub(&v1, &v2);
  //vm_println(v1);

#ifdef _ONLF_FAST_VEC
  double dot = vm_dot(&v1, &v2);
#else
  double dot = _vm_asm_dot(&v1, &v2);
#endif

  //vm_fprintln(stderr, v1);
  fprintf(stderr, "dot: %lf\n", dot);

  v3.x = 2;
  v3.y = 2;
  v3.z = 2;
  v3.w = 0;
  double factor = .5;

  _vm_asm_scale(&v3, &factor, &tmp);
  vm_fprintln(stderr, tmp);

  double mag = _vm_asm_magnitude(&v3);
  fprintf(stderr, "asm Magnitude: %lf\n", mag);
  double mag2 = vm_magnitude(v3);
  fprintf(stderr, "c   Magnitude: %lf\n", mag2);

  _vm_asm_norm(&v3, &tmp);
  vm_fprintln(stderr, tmp);

  _vm_asm_project(&v1, &v2, &tmp);
  fprintf(stderr, "_vm_asm_project: ");
  vm_fprintln(stderr, tmp);
  vm_project(v1, v2, &tmp);
  fprintf(stderr, "vm_project:      ");
  vm_fprintln(stderr, tmp);

}

void _print_vec(vm_vector *v){

  vm_fprintln(stderr, *v);

}

void _print_addr(long addr){

  fprintf(stderr, "Addr: 0x%016lx\n", addr);

}

void _print_double(double *d){

  fprintf(stderr, "Double: %lf\n", *d);

}

void _print_xmm_reg(struct __xmm_reg *reg){

  fprintf(stderr, "xmm register: (addr=0x%016lx)\n", reg);
  fprintf(stderr, "  Low double:  %lf\n", reg->low);
  fprintf(stderr, "  High double: %lf\n", reg->high);

}
